package com.share.design.chain.demo01;

import java.util.Objects;

/**
 * 零 处理器
 * @author caifan
 * @since 2022/11/7
 */
public class ZeroExecutor implements Executor {

    private Executor executor;

    @Override
    public void setNext(Executor executor) {
        this.executor = executor;
    }

    @Override
    public void handle(Integer num) {
        if (Objects.nonNull(num) && num == 0) {
            System.out.println("ZeroExecutor处理零:" + num);
        } else {
            if (Objects.nonNull(executor)) {
                System.out.println("==经过ZeroExecutor");
                executor.handle(num);
            } else {
                System.out.println("==经过ZeroExecutor,stop");
            }
        }
    }
}
